<?php
function install_tables() {
  global $wpdb;
  $charset_collate = "ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 

  $num = 0;
  $it_tables[$num]['table_name'] = $wpdb->prefix . 'WBPRO_sales';
  $it_tables[$num]['table_sql'] = "CREATE TABLE " . $wpdb->prefix . "sales (
  	  id mediumint(9) NOT NULL AUTO_INCREMENT,
		  time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
		  fname varchar(255) NULL,
		  passwd varchar(255) NULL,
		  email varchar(255) NULL,
		  contactno varchar(255) NULL,
		  address text NULL,
		  basic_info text NULL,
		  image text NULL,
		  profile_page text NULL,
		  sort_order INT(21) NOT NULL,
		  status INT(21) NOT NULL,
		  PRIMARY KEY id (id)
	) $charset_collate;";  

  $num++;
  $it_tables[$num]['table_name'] = $wpdb->prefix . 'WBPRO_settings';
  $it_tables[$num]['table_sql'] = "CREATE TABLE " . $wpdb->prefix . "settings (
  `id` int(21) NOT NULL AUTO_INCREMENT,
		  `name` varchar(50) NOT NULL,
		  `description` text NOT NULL,
		  `terms` text NOT NULL,
		  `link` text NOT NULL,
		  `status` tinyint(4) NOT NULL,
		  PRIMARY KEY (`id`)
	) $charset_collate;";

  foreach($it_tables as $it_table) {
    if(!$wpdb->get_var("SHOW TABLES LIKE '{$it_table['table_name']}'")) {
      $wpdb->query($it_table['table_sql']);
		}
  }
}
?>